package script.db
databaseChangeLog(logicalFilePath: 'script/db/lm_example.groovy') {
    def weight_c = 1
    if(helper.isOracle()){
    weight_c = 3
    }
    if(helper.isSqlServer()){
    weight_c = 2
    }
    changeSet(author: "xiuhong.chen@hand-china.com", id: "lm_example-2023-09-18-version-2"){
        if(helper.dbType().isSupportSequence()){
            createSequence(sequenceName: 'lm_example_s', startValue:"1")
        }
        createTable(tableName: "lm_example", remarks: "") {
            column(name: "id", type: "bigint",autoIncrement: true, startWith: "100000000",    remarks: "")  {constraints(primaryKey: true)} 
            column(name: "name", type: "varchar(" + 20* weight_c + ")",  remarks: "")  {constraints(nullable:"false")}  
            column(name: "created_by", type: "bigint",   defaultValue:"-1",   remarks: "创建人")  {constraints(nullable:"false")}  
            column(name: "last_updated_by", type: "bigint",   defaultValue:"-1",   remarks: "最近更新人")  {constraints(nullable:"false")}  
            column(name: "creation_date", type: "datetime",   defaultValueComputed :"CURRENT_TIMESTAMP",   remarks: "创建时间")  {constraints(nullable:"false")}  
            column(name: "last_update_date", type: "datetime",   defaultValueComputed :"CURRENT_TIMESTAMP",   remarks: "最近更新时间")  {constraints(nullable:"false")}  
            column(name: "object_version_number", type: "bigint",   defaultValue:"1",   remarks: "行版本号，用来处理锁")  {constraints(nullable:"false")}  
        }
       createIndex(tableName: "lm_example", indexName: "lm_example_name") {
           column(name: "name")
       }
    }
}